package vip.xiaonuo.biz.modular.lancerCategory.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.pojo.domain.BizCategory;
import vip.xiaonuo.biz.modular.pojo.dto.common.CommonDetailDTO;
import vip.xiaonuo.biz.modular.pojo.dto.edit.CategoryEditDTO;
import vip.xiaonuo.biz.modular.lancerCategory.service.BizCategoryService;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "分类管理(B端)")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@Validated
@RestController
@RequestMapping
public class BusCategoryController {
    @Autowired
    private BizCategoryService categoryService;
//
//    @ApiOperationSupport(order = 2)
//    @ApiOperation("分类详情查询")
//    @GetMapping("/detail")
//    public CommonResult<BizCategory> detail(@Valid CommonDetailDTO dto) {
//        BizCategory res = CategoryService.detail(dto);
//        return CommonResult.data(res);
//    }
//
//    @ApiOperationSupport(order = 5)
//    @ApiOperation("分类编辑")
//    @PostMapping("/edit")
//    public CommonResult<String> edit(@Valid CategoryEditDTO dto) {
//        CategoryService.edit(dto);
//        return CommonResult.ok();
//    }

    @ApiOperationSupport(order = 6)
    @ApiOperation("B端获取分类树选择器")
    @GetMapping("/biz/business/category/categoryTreeSelector")
    @SaCheckPermission("/biz/business/category/categoryTreeSelector")
    public CommonResult<List<Tree<String>>> categoryTreeSelector() {
        return CommonResult.data(categoryService.tree());
    }
}